const Koa=require('koa');
const router=require('koa-router')();
const parser=require('koa-parser');
const cors=require('koa2-cors');
const app=new Koa();
app.listen(3000,()=>{
    console.log(3000);
})
app.use(cors());
app.use(parser());
app.use(router.routes());
let star=[
    {id:3,name:'张一山',age:28,sex:'男'},
    {id:6,name:'江一燕',age:37,sex:'女'},
    {id:8,name:'曹一建',age:18,sex:'男'},
]
router.get('/data',async ctx=>{
    ctx.body=star;
})
router.post('/post',async ctx=>{
    let data=ctx.request.body.data;
    star.push(data);
    ctx.body=''
})